package com.qk.filter;

import jakarta.servlet.*;

import java.io.IOException;

/**
 * ClassName: DemoFilter
 * Package: com.qk.filter
 * Description:
 *
 * @Author zt
 * @Create 2025/7/31 16:01
 * @Version 1.0
 */
//@WebFilter(urlPatterns = "/*")
public class DemoFilter implements Filter {
    //初始化 - web服务器启动的时候执行，只执行一次
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("DemoFilter...init...");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("DemoFilter...doFilter...");

        //放行
        //filterChain.doFilter(servletRequest, servletResponse);
    }

    //销毁 - web服务器关闭的时候执行，只执行一次
    @Override
    public void destroy() {
        Filter.super.destroy();
    }
}
